Repository navigation
P23: coverage after Tests (capability coverage, opt-in) - #39
Merged
Merged
Conversation
When all examples pass, the Tests report lists which lines of the tested file's functions no example executed, each with its code («Zeile 11: return "ungenügend"»; consecutive lines of one function grouped as «Zeilen 8–12:»). When every line ran, a neutral note says so and that this doesn't show whether the examples check the edge cases. With the editor (the IDE), the same lines are marked in it until the file is edited or the program runs again. doctests.py records the lines with sys.monitoring during the examples only (each line once, then switched off, so loops cost nothing more). Counted are the statements in function bodies, also methods and nested functions, as Python's trace module counts them: not def lines, decorators, docstrings, code outside functions, other files such as libraries, or statements without bytecode of their own (global, while True). The capability is off by default. The embed switches it on only when "coverage" is listed in ?features= (a missing features keeps it off). check-runtime-coverage.py (in test:runtime) covers the reference cases and checks every case against Python's trace module; check-console-browser.mjs checks the report in Pyodide and the opt-in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…p-surface Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
P23, for Etappe 3 of «Funktionen». Decisions: all ★ except 2 (report only in the embed, marks only in the IDE) and the English full-coverage note as given.
What learners see
When all examples pass, the Tests report lists which lines of the tested file's functions no example executed, each with its code:
return "ungenügend"», consecutive lines of one function as «Zeilen 16–18:» with the lines belowThe box is neutral (grey bar, not the green «bestanden» style). With a failing example, or a file that doesn't load, nothing about coverage shows.
In the IDE (with the editor) the same lines are also marked in the editor: a pale orange line background and a bar in the gutter, using the hint tokens (the editor's own background is
--glp-surface). The marks go away on the first edit of that file, on Run, on the next Tests and on reset.What counts (
src/runtime/doctests.py)deflines, decorators, docstrings, class bodies, code outside functions, other files (libraries), statements without bytecode (global,while True).if note >= 4:).sys.monitoring(Python 3.12, Pyodide 0.26.2) during the examples only, so a top-levelprint(f(1))doesn't count. Each line reports once and is then switched off: a loop that runs 2 million times took 0.036 s without recording and 0.040 s with it.Opt-in
coverage, defaultfalse, so existing hosts are unchanged.coverageis listed in?features=. A missingfeatures(which otherwise means "everything") keeps it off.featuresis a query parameter.Checks
scripts/check-runtime-coverage.py(new, intest:runtime):ist_genuegendfully covered,bewertung→ line 11,vorzeichen→ line 12)global/while True/nesteddef,try/methods/decorators/lambdas, a failing exampletracemodulecheck-console-browser.mjs, in Chrome with Pyodide:bewertungandist_genuegend(which also shows thatsys.monitoringworks in Pyodide)coverageinfeatures, and nothing withoutfeaturesLint (known warning only), both builds,
test:protocol,test:hints,test:runtimeandtest:consolepass locally. The IDE was checked locally with this build: marks on the right lines, cleared on edit.After the merge: tag
v0.1.17, then the IDE PR (bump +coverage: true) and the macro PR (features=coverage).🤖 Generated with Claude Code